package com.zuihai.app.mvp.ui.utils;

import android.content.Context;
import android.widget.ImageView;

import com.blankj.utilcode.util.LogUtils;
import com.bumptech.glide.Glide;
import com.zuihai.app.R;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Administrator on 2017/6/8 0008.
 */

public class MyUtils {
    public static boolean isScroll = false;
    public static boolean isThreePicture = false;
    public static boolean isFangKe = false;

    public static String timeConvertUtil(long time) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm");
        String date = simpleDateFormat.format(new Date(time));
        return date;
    }

    public static String timeConvertYearUtil(long time) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
        String date = simpleDateFormat.format(new Date(time));
        return date;
    }

    public static String currentTimeUtil() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
        String date = simpleDateFormat.format(new Date(System.currentTimeMillis()));
        return date;
    }


    public static void headImageGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.img_portrait)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }

    public static void backgroundGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.img_portrait)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }


    public static void enlargeGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.position_rectangle_big)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }

    public static void loadPictureDetailGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.button_album)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }


    public static void big11Glide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.position_square_medium)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }
    public static void big11Glide(Context context, int imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.position_square_medium)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }

    public static void big11Glide(Context context, String imagePath, ImageView headView, int width) {
        Glide.with(context).load(imagePath).
                placeholder(R.mipmap.position_square_medium).
                dontAnimate().into(headView);
    }


    public static void enlargelistGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.position_rectangle_big)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }

    public static void friendsGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.position_square_medium)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }

    public static void loadingGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.drawable.frame_loading)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }

    //main下面5个
    public static void mainGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.zhanwei)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }

    //首页发现的栏目图标
    public static void itemIconGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.zhanwei)
                .crossFade()
                .dontAnimate()
                .into(headView);

    }

    //发布的栏目图标
    public static void releaseGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                .placeholder(R.mipmap.zhanwei)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }



    //MainActivity下 的Selecetd切换栏目的占位图  选中
    public static void bottomGlideSelected(Context context, String imagePath, ImageView headView, int position) {
        switch (position) {
            case 0:
                Glide.with(context).load(imagePath)
                        .placeholder(R.mipmap.button_bottom_home_selected)
                        .into(headView);
                break;
            case 1:
                Glide.with(context).load(imagePath)
                        .placeholder(R.mipmap.button_bottom_find_selected)
                        .into(headView);
                break;
            case 2:
                Glide.with(context).load(imagePath)
                        .placeholder(R.mipmap.button_bottom_release)
                        .crossFade()
                        .dontAnimate()
                        .into(headView);

                break;
            case 3:
                Glide.with(context).load(imagePath)
                        .placeholder(R.mipmap.button_bottom_friends_selected)
                        .crossFade()
                        .dontAnimate()
                        .into(headView);


                break;
            case 4:
                Glide.with(context).load(imagePath)
                        .placeholder(R.mipmap.button_bottom_my_selected)
                        .crossFade()
                        .dontAnimate()
                        .into(headView);

                break;

        }

    }

    //MainActivity下 的Selecetd切换栏目的占位图 未选中
    public static void bottomGlideSelect(Context context, String imagePath, ImageView headView, int position) {
        LogUtils.e("URLTAB NET bottomGlideSelect position : "+position);
        switch (position) {
            case 0:
                if (imagePath.length() < 2) {
                    Glide.with(context).load(R.mipmap.button_bottom_home)
                            .into(headView);
                } else {
                    Glide.with(context).load(imagePath)
                            .placeholder(R.mipmap.button_bottom_home)
                            .into(headView);
                }
                break;
            case 1:
                if (imagePath.length() < 2) {
                    Glide.with(context).load(R.mipmap.button_bottom_find)
                            .crossFade()
                            .dontAnimate()
                            .into(headView);
                    LogUtils.e("URLTAB NET case 1 imagePath.length() < 2");
                } else {
                    Glide.with(context).load(imagePath)
                            .placeholder(R.mipmap.button_bottom_find)
                            .crossFade()
                            .dontAnimate()
                            .into(headView);
                    LogUtils.e("URLTAB NET case 1 imagePath.length() >= 2");
                }
                break;
            case 2:
                if (imagePath.length() < 2) {
                    Glide.with(context).load(R.mipmap.button_bottom_release)
                            .crossFade()
                            .dontAnimate()
                            .into(headView);
                } else {
                    Glide.with(context).load(imagePath)
                            .placeholder(R.mipmap.button_bottom_release)
                            .crossFade()
                            .dontAnimate()
                            .into(headView);
                }
                break;
            case 3:
                if (imagePath.length() < 2) {
                    Glide.with(context).load(R.mipmap.button_bottom_friends)
                            .crossFade()
                            .dontAnimate()
                            .into(headView);
                } else {
                    Glide.with(context).load(imagePath)
                            .placeholder(R.mipmap.button_bottom_friends)
                            .crossFade()
                            .dontAnimate()
                            .into(headView);
                }

                break;
            case 4:
                if (imagePath.length() < 2) {
                    Glide.with(context).load(R.mipmap.button_bottom_my)
                            .crossFade()
                            .dontAnimate()
                            .into(headView);
                } else {
                    Glide.with(context).load(imagePath)
                            .placeholder(R.mipmap.button_bottom_my)
                            .crossFade()
                            .dontAnimate()
                            .into(headView);
                }
                break;

        }
    }

    //开平广告的占位图
    public static void screenGlide(Context context, String imagePath, ImageView headView) {
        Glide.with(context).load(imagePath)
                // .placeholder(R.mipmap.start)
                .crossFade()
                .dontAnimate()
                .into(headView);
    }


}
